from django.db import models

# Create your models here.
class Draw(models.Model):
    id = models.AutoField(primary_key=True, db_column='DRAW_ID')
    no = models.CharField(db_column='DRAW_NO', max_length=20, null=False)
    gameId = models.IntegerField(db_column="GAME_ID", null=False)
    status = models.IntegerField(db_column="DRAW_STATUS", null=False)
    result = models.CharField(db_column='DRAW_RESULT', max_length=100)
    prizeLvl = models.CharField(db_column='PRIZE_LVL', max_length=4000)
    class Meta:
        db_table = 'DRAW'

class VlUser(models.Model):
    id = models.AutoField(primary_key=True, db_column='USER_ID')
    name = models.CharField(db_column='USER_NAME', max_length=30, null=False)
    email = models.EmailField(db_column='USER_EMAIL', max_length=30, null=False)
    money = models.DecimalField(db_column="USER_MONEY", decimal_places=10, max_digits=14)
    prize = models.DecimalField(db_column="USER_PRIZE", decimal_places=10, max_digits=14)
    sinaToken = models.CharField(db_column="SINA_TOKEN", max_length=100)
    class Meta:
        db_table = "VL_USER"

class UserMoneyAddition(models.Model):
    addId = models.AutoField(primary_key=True, db_column="ADD_ID")
    userId = models.ForeignKey(VlUser, db_column="USER_ID")
    money = models.DecimalField(db_column="ADD_MONEY", decimal_places=10, max_digits=14)
    time = models.DateTimeField(db_column="ADD_TIME")
    type = models.IntegerField(db_column="ADD_MONEY_TYPE")

    class  Meta:
        db_table = "USER_MONEY_ADDITION"

class UserVote(models.Model):
    voteId = models.AutoField(primary_key=True, db_column="VOTE_ID", null=False)
    userId = models.ForeignKey(VlUser, db_column="USER_ID")
    drawId = models.ForeignKey(Draw, db_column="DRAW_ID")
    # vote content , it will contain vote
    content = models.CharField(max_length=4000, db_column="VOTE_CONTENT")
    # chance one lottery ticket's price=chance*2. in big prize addition vote will recode 0.5
    chance = models.DecimalField(db_column="VOTE_CHANCE", decimal_places=10, max_digits=12)
    # sale time
    time = models.DateTimeField(db_column="VOTE_TIME")
    # multiple
    multiple = models.DecimalField(db_column="VOTE_MULTIPLE", decimal_places=10, max_digits=12)

    class Meta:
        db_table = "USER_VOTE"

class UserWin(models.Model):
    winId = models.CharField(primary_key=True, max_length=30, db_column="WIN_ID")
    voteId = models.ForeignKey(UserVote, db_column="VOTE_ID")
    userId = models.ForeignKey(VlUser, db_column="USER_ID")
    drawId = models.ForeignKey(Draw, db_column="DRAW_ID")
    przLvl = models.IntegerField(db_column="PRZ_LVL")
    content = models.CharField(max_length=4000, db_column="VOTE_CONTENT")
    chance = models.DecimalField(db_column="VOTE_CHANCE", decimal_places=10, max_digits=12)
    time = models.DateTimeField(db_column="VOTE_TIME")
    # one chance's prize
    winChance = models.DecimalField(db_column="WIN_CHANCE", decimal_places=10, max_digits=14)
    prize = models.DecimalField(db_column="WIN_PRIZE", decimal_places=10, max_digits=14)
    #
    multiple = models.DecimalField(db_column="VOTE_MULTIPLE", decimal_places=10, max_digits=12)

    class Meta:
        db_table = "USER_WIN"